<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>今日爆款</title>
    <link rel="stylesheet" href="css/recommend.css">
</head>

<body>
    <div class="main">
        <h2>今日爆款</h2>
        <ul>
            <?php
                require ("connect.php");

                $query = "select * from tb_shangpin where recommend = 1 limit 0,9";

                $result = mysqli_query($link, $query) or die('查询失败'.mysqli_error());

                while($row = mysqli_fetch_array($result)){
            ?>
            <li>
                <div class="left">
                    <a href="details.php?id=<?php echo $row['id']; ?>&name=<?php echo $row['name']; ?>">
                        <img src="<?php echo $row['photo']; ?>" alt="" width="50" height="50" />
                    </a>
                </div>

                <div class="right">
                    <h5>
                        <span>商品名称：</span>
                        <a href="details.php?id=<?php echo $row['id']; ?>&name=<?php echo $row['name']; ?>">
                            <?php
                            if (mb_strlen($row['name'], 'UTF-8') >= 7) {
                                echo mb_substr($row['name'], 0, 7, 'UTF-8');
                            } else {
                                echo $row['name'];
                            }
                            ?>
                        </a>
                    </h5>
                    <p class="brand">
                        品牌：<span><?php echo $row['brand']; ?></span>
                    </p>
                    <p>
                        价格：￥<span><?php echo number_format($row['price'],2); ?></span>
                    </p>
                </div>

            </li>
            <?php
            }
            mysqli_close($link);
            ?>
        </ul>
    </div>

</body>

</html>